package org.example;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

public class TestHashMap {

    //capacity loadFacotry threshold size

    public static void main(String[] args) throws Exception {

        Map<String, String> map = new HashMap<String, String>();



        map.put("1", "1");
        map.put("2", "2");
        map.put("3", "3");
        map.put("4", "4");
        map.put("5", "5");
        map.put("6", "6");
        map.put("7", "7");
        map.put("8", "8");
        map.put("9", "9");
        map.put("10", "10");
        map.put("11", "11");
        map.put("12", "12");

        Class<? extends Map> aClass = map.getClass();
        Method capacity = aClass.getDeclaredMethod("capacity");
        capacity.setAccessible(true);


        Field threshold = aClass.getDeclaredField("threshold");
        threshold.setAccessible(true);
        System.out.println("capacity=" + capacity.invoke(map));
        System.out.println("threshold=" + threshold.get(map));
        System.out.println("size=" + map.size());

        //----------
        System.out.println("------------------------");
        map.put("13","13");


        System.out.println("capacity=" + capacity.invoke(map));
        System.out.println("threshold=" + threshold.get(map));
        System.out.println("size=" + map.size());


    }
}
